package com.flash.BusinessParameters.controller;

import com.flash.BusinessParameters.entity.BondSetting;
import com.flash.BusinessParameters.service.BondSettingService;
import com.flash.BusinessParameters.service.impl.BondSettingServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 债券信息
 */
@Controller
public class BondSettingController {

    @Autowired
    private BondSettingService bondSettingService;

    @RequestMapping("/toBondSetting")
    public String toBondSetting(){
        return "bondSetting";
    }

    @RequestMapping("/selectBondSetting")
    @ResponseBody
    private Map selectBondSetting(BondSetting bondSetting,int page,int limit){
        List<BondSetting> bondSettingList = bondSettingService.selectBondSettingMap(bondSetting, page, limit);
        System.out.println("得到了"+bondSetting);
        int count = bondSettingService.selectCountBondSetting();
        Map map=new HashMap();
        map.put("code","");
        map.put("msg","");
        map.put("data",bondSettingList);
        map.put("count",count);
        System.out.println(bondSettingList);
        return map;
    }

    @RequestMapping("/insertBondSetting")
    @ResponseBody
    public int insertBondSetting(BondSetting bondSetting){
        System.out.println(bondSetting);
        return bondSettingService.insertBondSetting(bondSetting);
    }

    @RequestMapping("/deleteBondSetting/{bondId}")
    @ResponseBody
    public int deleteBondSetting(@PathVariable int bondId){
        return bondSettingService.deleteBondSetting(bondId);
    }

    @RequestMapping("/updateBondSetting")
    @ResponseBody
    public int updateBondSetting(BondSetting bondSetting){
        return  bondSettingService.updateBondSetting(bondSetting);
    }
}
